<!--
 * @Author: Wangtao
 * @Date: 2020-09-21 09:55:09
 * @LastEditors: Wangtao
 * @LastEditTime: 2020-11-30 11:58:49
-->
<template>
  <CardLayout>
    <template slot="card">
      <CardGroup ref="cardGroup"></CardGroup>
    </template>
    <template slot="detail">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </template>
  </CardLayout>
</template>
<script lang="ts">
import CardLayout from '@components/cardLayout/index.vue'
import CardGroup from './CallCardGroup.vue'
import { Component, Vue } from 'vue-property-decorator'
// import { CommonModule } from '@/store/modules/common'
@Component({ name: 'CallIndex', components: { CardLayout, CardGroup } })
export default class CallIndex extends Vue {
  [x: string]: any
  private microApp: any
  private currentRoute: string = ''
  private beforeRouteLeave (to: any, from: any, next: any) {
    this.currentRoute = from.fullPath
    next()
  }

  private beforeRouteEnter (to: any, from: any, next: any) {
    next((vm: any) => {
      if (to.params.id && to.params.id !== '') {
        // 从电话小卡片跳过来的，啥也不干
      } else if (vm.currentRoute) {
        // 点击其他模块回到当前模块离开时的模块 || 刷新系统
        vm.$router.push({ path: vm.currentRoute })
      }
    })
  }

  private activated () {
    // console.log('activated 1', this.$bus)
  }

  private deactivated () {
    // const status = this.$bus.$subscribed('initCustomerCard')
    // if (status) {
    //   this.$bus.$off('initCustomerCard')
    // }
  }
}
</script>
